//search模块的小仓库
import { reqSearchInfo } from "@/api"
const actions = {
    //至少传递一个空对象
    async getSearchList(context, params = {}) {
        let result = await reqSearchInfo(params);
        if (result.code == 200) {
            context.commit("SEARCHLIST", result.data);
        }
    }
}
const mutations = {
    SEARCHLIST(state, searchList) {
        state.searchList = searchList;
    }
}
const state = {
    searchList: {}
}
//计算属性。 主要作用：简化仓库中的数据。
const getters = {
    attrsList(state) {
        return state.searchList.attrsList || [];
    },
    trademarkList(state) {
        return state.searchList.trademarkList || [];
    },
    goodsList(state) {
        return state.searchList.goodsList || [];
    },
}

export default {
    namespaced: true,
    actions,
    mutations,
    state,
    getters
}